<template>
  <div class="top">
    <div class="container flex align-center">
      <div class="nav flex align-cente">
        <div
          v-for="(item, index) in navList"
          :key="index"
          class="flex align-center"
          :class="nav_act == index ? 'active' : ''"
          v-on:mousemove="navhover(index)"
          @mouseleave="mouseLeave"
          @click="navclcik(index, item.path)"
        >{{ item.text }}</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "navList",
  data() {
    return {
      navList: [
        {
          path: "/indexpage",
          text: "首页",
        },
        {
          path: "/newsDetails",
          text: "新闻中心",
        },
        {
          path: "/serveCenter",
          text: "服务中心",
        },
        {
          path: "/Knowledge",
          text: "煤炭知识",
        },
        {
          path: "/aboutUS",
          text: "关于我们",
        },
      ],
      nav_act: 0,
      hea_act: 0,
    };
  },
  methods: {
    mouseLeave() {
      this.nav_act = this.hea_act;
    },
    navclcik(index, path) {
      this.nav_act = index;
      this.hea_act = index;
      this.$router.push({
        //核心语句
        path: path,
      });
    },
    navhover(data) {
      this.nav_act = data;
    },
  },
};
</script>

<style lang="stylus" scoped>
.top {
  width: 100%;
  height: 70px;
  background:rgba(235, 66, 76, 1);
  .container {
    padding-top: 4px;
    height: 70px;
  }
}

.nav>div {
  height: 58px;
  margin-left: 100px;
  font-size: 20px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.6);
  padding: 0 20px;
  border-bottom: 4px solid transparent;
  cursor: pointer;
}

.nav>div.active {
  color: #ffffff;
  border-color: #ffffff;
  // border-image: -webkit-linear-gradient(to right, #00036B, #409EFF) 30 30;
  // border-image: -moz-linear-gradient(to right, #00036B, #409EFF) 30 30;
  // border-image: linear-gradient(to right, #00036B, #409EFF) 30 30;
}
</style>
